﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Drive.Support.Extensions
{
    public static class PagedExtension
    {
        public static PagedList<T> ToPagedList<T>(this IQueryable<T> source, int page, int size)
        {
            if (size > 50)
                throw new System.Exception("请求姿势不正确");
            var total = source.Count();
            var list = source.Skip((page - 1) * size).Take(size).ToList();
            return new PagedList<T>(page, size, total, list);
        }
    }
}
